{%TEMPLATE->struct/head%}
{%TEMPLATE->struct/menu%}
<h2>Preconfigured task details</h2>
{%TEMPLATE->struct/messages%}
<br>
<div class="card">
  <div class="table-responsive">
    <table class="table table-bordered">
      <tr>
        <th>Property</th>
        <th>Value</th>
      </tr>
      <tr>
        <td>ID:</td>
        <td>
          <code>[[pretask.getId()]]</code>
          {{IF [[accessControl.hasPermission([[$DAccessControl::CREATE_PRETASK_ACCESS]])]]}}
            <form style ='float: right;' action="pretasks.php" method="POST" onSubmit="if (!confirm('Really delete preconfigured task [[pretask.getId()]]?')  || ({{IF [[isUsed]]}}true{{ELSE}}false{{ENDIF}} && !confirm('This task is used in a Supertask, are you sure you really want to delete it?'))) return false;">
              <input type="hidden" name="action" value="[[$DPretaskAction::DELETE_PRETASK]]">
              <input type="hidden" name="csrf" value="[[csrf]]">
              <input type="hidden" name="pretaskId" value="[[pretask.getId()]]">
              <button type="submit" class='btn btn-danger' data-toggle="tooltip" data-placement="top" title="Delete"><i class="fas fa-trash" aria-hidden="true"></i></button>
            </form>
          {{ENDIF}}
        </td>
      </tr>
      <tr>
        <td>Name:</td>
        <td>
          {{IF [[accessControl.hasPermission([[$DAccessControl::MANAGE_PRETASK_ACCESS]])]]}}
            <form class='form-inline' action="pretasks.php?id=[[pretask.getId()]]" method="POST">
              <input type="hidden" name="action" value="[[$DPretaskAction::RENAME_PRETASK]]">
              <input type="hidden" name="pretaskId" value="[[pretask.getId()]]">
              <input type="text" class='form-control' name="name" size="25" value="[[pretask.getTaskName()]]" title="Name">&nbsp;&nbsp;
              <input type="hidden" name="csrf" value="[[csrf]]">
              <button type="submit" class='btn {{IF [[toggledarkmode]] > 0}}btn-primary{{ELSE}}btn-light{{ENDIF}}' data-toggle="tooltip" data-placement="top" title="Set"><i class="fas fa-save" aria-hidden="true"></i></button>
            </form>
          {{ELSE}}
            [[pretask.getTaskName()]]
          {{ENDIF}}
        </td>
      </tr>
      <tr>
        <td>Attack command:</td>
        <td>
          {{IF [[accessControl.hasPermission([[$DAccessControl::CREATE_PRETASK_ACCESS]])]]}}
            <form class='form-inline' action="pretasks.php?id=[[pretask.getId()]]" onsubmit="return confirm('Do you really want to change the attack command?')" method="POST">
              <input type="hidden" name="action" value="[[$DPretaskAction::CHANGE_ATTACK]]">
              <input type="hidden" name="pretaskId" value="[[pretask.getId()]]">
              <input type="hidden" name="csrf" value="[[csrf]]">
              <input type="text" style="width: 80%;" name="attackCmd" class="form-control mx-1" title="Attack Command" value="[[htmlentities([[pretask.getAttackCmd()]], ENT_QUOTES, 'UTF-8')]]">
              <button type="submit" class='btn btn-warning mx-1' data-toggle="tooltip" data-placement="top" title="Change"><i class="fas fa-save" aria-hidden="true"></i></button>
            </form>
          {{ELSE}}
            <pre>[[htmlentities([[pretask.getAttackCmd()]], ENT_QUOTES, "UTF-8")]]</pre>
          {{ENDIF}}
        </td>
      </tr>
      <tr>
        <td>Chunk size:</td>
        <td>
          {{IF [[accessControl.hasPermission([[$DAccessControl::MANAGE_PRETASK_ACCESS]])]]}}
            <form class='form-inline' action="pretasks.php?id=[[pretask.getId()]]" method="POST">
              <input type="hidden" name="action" value="[[$DPretaskAction::SET_TIME]]">
              <input type="hidden" name="pretaskId" value="[[pretask.getId()]]">
              <input type="hidden" name="csrf" value="[[csrf]]">
              <input type="text" class='form-control' name="chunktime" size="5" value="[[pretask.getChunkTime()]]" title="Chunk Time">&nbsp; seconds &nbsp;
              <button type="submit" class='btn {{IF [[toggledarkmode]] > 0}}btn-primary{{ELSE}}btn-light{{ENDIF}}' data-toggle="tooltip" data-placement="top" title="Set"><i class="fas fa-save" aria-hidden="true"></i></button>
            </form>
          {{ELSE}}
            [[pretask.getChunkTime()]] seconds
          {{ENDIF}}
        </td>
      </tr>
      <tr>
        <td>Color:</td>
        <td>
          <form class='form-inline' id="taskcolor" action="pretasks.php?id=[[pretask.getId()]]" method="POST">
            <input type="hidden" name="action" value="[[$DPretaskAction::SET_COLOR]]">
            <input type="hidden" name="pretaskId" value="[[pretask.getId()]]">
            <input type="hidden" name="csrf" value="[[csrf]]">
            #<input type="text" class='form-control color {required:false}' size="6" name="color" value="[[pretask.getColor()]]" title="Color">&nbsp;&nbsp;
            {{IF [[accessControl.hasPermission([[$DAccessControl::MANAGE_PRETASK_ACCESS]])]]}}
              <button type="submit" class='btn {{IF [[toggledarkmode]] > 0}}btn-primary{{ELSE}}btn-light{{ENDIF}}' data-toggle="tooltip" data-placement="top" title="Set"><i class="fas fa-save" aria-hidden="true"></i></button>
            {{ENDIF}}
          </form>
        </td>
      </tr>
      <tr>
        <td>Benchmark Type:</td>
        <td>
          {{IF [[pretask.getUseNewBench()]] == 0}}
            Runtime Benchmark
          {{ELSE}}
            Speed Test
          {{ENDIF}}
        </td>
      </tr>
      <tr>
        <td>Status timer:</td>
        <td>[[pretask.getStatusTimer()]] seconds</td>
      </tr>
      <tr>
        <td>Priority:</td>
        <td>
          {{IF [[accessControl.hasPermission([[$DAccessControl::MANAGE_PRETASK_ACCESS]])]]}}
            <form class='form-inline' action="pretasks.php?id=[[pretask.getId()]]" method="POST">
              <input type="hidden" name="action" value="[[$DPretaskAction::SET_PRIORITY]]">
              <input type="hidden" name="pretaskId" value="[[pretask.getId()]]">
              <input type="hidden" name="csrf" value="[[csrf]]">
              <input type="text" class='form-control' name="priority" size="4" value="[[pretask.getPriority()]]" title="Priority">&nbsp;&nbsp;
              <button type="submit" class='btn {{IF [[toggledarkmode]] > 0}}btn-primary{{ELSE}}btn-light{{ENDIF}}' data-toggle="tooltip" data-placement="top" title="Set"><i class="fas fa-save" aria-hidden="true"></i></button>
            </form>
          {{ELSE}}
            [[pretask.getPriority()]]
          {{ENDIF}}
        </td>
      </tr>
      <tr>
        <td>Max agents:</td>
        <td>
          {{IF [[accessControl.hasPermission([[$DAccessControl::MANAGE_PRETASK_ACCESS]])]]}}
            <form class='form-inline' action="pretasks.php?id=[[pretask.getId()]]" method="POST">
              <input type="hidden" name="action" value="[[$DPretaskAction::SET_MAX_AGENTS]]">
              <input type="hidden" name="pretaskId" value="[[pretask.getId()]]">
              <input type="hidden" name="csrf" value="[[csrf]]">
              <input type="text" class='form-control' name="maxAgents" size="4" value="[[pretask.getMaxAgents()]]" title="Max agents">&nbsp;&nbsp;
              <button type="submit" class='btn {{IF [[toggledarkmode]] > 0}}btn-primary{{ELSE}}btn-light{{ENDIF}}' data-toggle="tooltip" data-placement="top" title="Set"><i class="fas fa-save" aria-hidden="true"></i></button>
            </form>
          {{ELSE}}
            [[pretask.getMaxAgents()]]
          {{ENDIF}}
        </td>
      </tr>
      <tr>
        <td>Is CPU only task:</td>
        <td>
          {{IF [[accessControl.hasPermission([[$DAccessControl::MANAGE_PRETASK_ACCESS]])]]}}
            <form class='form-inline' action="pretasks.php?id=[[pretask.getId()]]" method="POST">
              <input type="hidden" name="action" value="[[$DPretaskAction::SET_CPU_TASK]]">
              <input type="hidden" name="pretaskId" value="[[pretask.getId()]]">
              <input type="hidden" name="csrf" value="[[csrf]]">
              <select name="isCpu" class="form-control" title="CPU">
                <option value="0"{{IF [[pretask.getIsCpuTask()]] == 0}} selected{{ENDIF}}>No</option>
                <option value="1"{{IF [[pretask.getIsCpuTask()]] == 1}} selected{{ENDIF}}>Yes</option>
              </select>&nbsp;&nbsp;
              <button type="submit" class='btn {{IF [[toggledarkmode]] > 0}}btn-primary{{ELSE}}btn-light{{ENDIF}}' data-toggle="tooltip" data-placement="top" title="Set"><i class="fas fa-save" aria-hidden="true"></i></button>
            </form>
          {{ELSE}}
            {{IF [[pretask.getIsCpuTask()]] == 1}}
              Yes
            {{ELSE}}
              No
            {{ENDIF}}
          {{ENDIF}}
        </td>
      </tr>
      <tr>
        <td>Is small task:</td>
        <td>
          {{IF [[accessControl.hasPermission([[$DAccessControl::MANAGE_PRETASK_ACCESS]])]]}}
            <form class='form-inline' action="pretasks.php?id=[[pretask.getId()]]" method="POST">
              <input type="hidden" name="action" value="[[$DPretaskAction::SET_SMALL_TASK]]">
              <input type="hidden" name="pretaskId" value="[[pretask.getId()]]">
              <input type="hidden" name="csrf" value="[[csrf]]">
              <select name="isSmall" class="form-control" title="Small">
                <option value="0"{{IF [[pretask.getIsSmall()]] == 0}} selected{{ENDIF}}>No</option>
                <option value="1"{{IF [[pretask.getIsSmall()]] == 1}} selected{{ENDIF}}>Yes</option>
              </select>&nbsp;&nbsp;
              <button type="submit" class='btn {{IF [[toggledarkmode]] > 0}}btn-primary{{ELSE}}btn-light{{ENDIF}}' data-toggle="tooltip" data-placement="top" title="Set"><i class="fas fa-save" aria-hidden="true"></i></button>
            </form>
          {{ELSE}}
            {{IF [[pretask.getIsSmall()]] == 1}}
              Yes
            {{ELSE}}
              No
            {{ENDIF}}
          {{ENDIF}}
        </td>
      </tr>
    </table>
  </div>
  {{IF [[sizeof([[attachedFiles]])]] > 0}}
    <h3>Attached files</h3>
    <div class="card">
      <div class="table-responsive">
        <table class="table table-bordered">
          <tr>
            <th>ID</th>
            <th>Filename</th>
            <th>Size</th>
          </tr>
          {{FOREACH file;[[attachedFiles]]}}
            <tr>
              <td>[[file.getId()]]</td>
              <td>
                {{IF [[accessControl.hasPermission([[$DAccessControl::VIEW_FILE_ACCESS]])]]}}
                  <a href="files.php#[[file.getId()]]">[[file.getFilename()]]</a>
                {{ELSE}}
                  [[file.getFilename()]]
                {{ENDIF}}
                {{IF [[file.getIsSecret()]] == 1}}
                  <span class="fas fa-lock" aria-hidden="true"></span>
                {{ENDIF}}
              </td>
              <td class='num'>
                [[Util::nicenum([[file.getSize()]])]]B
              </td>
            </tr>
          {{ENDFOREACH}}
        </table>
      </div>
    </div>
  </div>
{{ENDIF}}
{%TEMPLATE->struct/foot%}